<?php


namespace app\admin\service\control;

use app\admin\model\control\JackpotLottery;
use app\admin\service\BaseService;

/**
 * @author tangsan
 * Class ActionLogService
 * @package app\admin\service
 */
class JackpotLotteryService extends BaseService
{
    /**
     * 构造函数
     * @author tangsan
     * ActionLogService constructor.
     */
    public function __construct()
    {
        $this->model = new JackpotLottery();
    }

    /**
     * 获取数据列表
     * @return array
     * @author tangsan
     */
    public function getList()
    {
        $param = request()->param();
        // 用户账号
        $ChannelID = getter($param, "ChannelID");
        if ($ChannelID) {
            $map[] = ["ChannelID", '=', $ChannelID];
        }
        $map = [];
        $sort = 'ChannelID desc';


        $is_sql = 0;
        // 获取参数
        $argList = func_get_args();
        if (!empty($argList)) {
            // 查询条件
            $map = (isset($argList[0]) && !empty($argList[0])) ? $argList[0] : [];
            // 排序
            $sort = (isset($argList[1]) && !empty($argList[1])) ? $argList[1] : 'ChannelID desc';
            // 是否打印SQL
            $is_sql = isset($argList[2]) ? isset($argList[2]) : 0;
        }
        $result = $this->model->where($map)->order($sort)->page(PAGE, PERPAGE)->select()->toArray();
        // 打印SQL
//        if ($is_sql) {
//            echo $this->model->getLastSql();
//        }

        //获取数据总数
        $count = $this->model->where($map)->count();

        //返回结果
        $message = array(
            "msg" => '操作成功',
            "code" => 0,
            "data" => $result,
            "count" => $count,
        );
        return $message;
    }

}